package cn.silver.module.oss.runner;

import cn.silver.module.oss.OssPolicyEnums;
import cn.silver.module.oss.service.IOssConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import static cn.silver.framework.core.constant.CacheConstants.MODEL_MAP;

/**
 * 初始化 system 模块对应业务数据
 *
 * @author Lion Li
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class OssApplicationRunner implements ApplicationRunner {

    private final IOssConfigService configService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("开始初始化OSS配置");
        this.configService.init();
        log.info("初始化OSS配置成功");
        MODEL_MAP.put("oss-config-policy", OssPolicyEnums.getModels());
    }

}
